package com.liwei.controller;

import com.liwei.beans.User;
import com.liwei.dto.ResultDTO;
import com.liwei.services.UserServices;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {

    @Autowired
    UserServices userServices;

    @RequestMapping("in.action")
    public ResultDTO in(@Valid String loginAct, String loginPwd){
        ResultDTO resultDTO = new ResultDTO();
        resultDTO.setResult(resultDTO.SUCCESS);
        User byUser = userServices.getByUser(loginAct, loginPwd);
        if (byUser==null){
            resultDTO.setResult(resultDTO.ERROR);
            resultDTO.setMess("登录失败,账号或密码错误!");
        }
        return resultDTO;
    }
}
